#ifndef BINANCEC__SERVER_STRATEGYSERVICE_H
#define BINANCEC__SERVER_STRATEGYSERVICE_H

#include <unistd.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include "CoinPrice.h"
#include "../../json.hpp"
using json = nlohmann::json;

const int MAX_READ_BUFF = 2048;
static int readTimes = 0;

class StrategyService
{
public:
    void init(int, int);
    void readJson();
    void writeJson();
    int comparePrice(Coin, int);
    void buyCoin(Coin, int);//后续使用复杂的购买卖出策略时可以使用这两个函数封装算出来
    void sellCoin(Coin, int);
    bool readCoinsPrice(const json&, json&);

    StrategyService();
    CoinPrice* coinPrice;
    int state;//状态位0表示读取，1表示写入
    int sockFd;
    char readMessage[1024];
    char writeMessage[1024];
    int epollFd;
};

#endif //BINANCEC__SERVER_STRATEGYSERVICE_H
